<template>
<div class="container">
  <van-nav-bar
      :title="headTitle"
      left-text="返回"
      right-text="发布求购"
      left-arrow
      fixed
      @click-left="onClickLeft"
      @click-right="onClickRight"
  />
  <div class="mainContent">
    <div class="contentItem" v-for="(item,idx) in wantList" :key="idx">
       <div style="width: 80%"><p> <span style="color: #39a9ed;font-weight: bold">{{item.nick_name}}:</span> {{item.wantContent}}</p></div>
      <div class="toShe"><van-button @click="toFindShe(item)" type="primary" size="mini">联系他</van-button></div>
    </div>
  </div>
</div>
</template>

<script>
export default {
  name: "WantBuy",
  data(){
    return{
       headTitle:"求购社区",
       wantList:[]
    }
  },
  created() {
    this.getWantList()
  },
  methods:{
    getWantList(){
      this.$http.get('/WantBuy/getWantBuy').then(res=>{
        this.wantList=res.data.result
      })
    },
    toFindShe(data){
      //
      this.$router.push({
        path: `/Chart/chatList/${data.send_id}`
      })
    },
    onClickLeft(){
      this.$router.back()
    },
    onClickRight(){
      this.$router.push('/WantBuySend')
    }

  }
}
</script>

<style scoped lang="less">
html{
  height: 500px;
  background: #39a9ed;
  .container{
    padding-top: 50px;
    height: 100%;
    .mainContent{
      width: 100%;
      .contentItem{
        border-radius: 3px;
        padding: 5px;
        box-sizing: border-box;
        background:#cccccc;
        position: relative;
        margin: 5px 10px;
       p{
         word-wrap: break-word;
         line-height:25px;
         //overflow:hidden;
         //text-overflow:ellipsis;
         //white-space:nowrap;
       }
        .toShe{
          position: absolute;
          right:0px;
          top:0px;
        }


      }
    }
  }
}

</style>
